<template>
  <div id="centerRight2">
    <div class="bg-color-black">
      <div class="d-flex pt-2 pl-2">
        <span>
          <icon name="align-left" class="text-icon"></icon>
        </span>
        <span class="fs-xl text mx-2">风险节点分布</span>
      </div>
      <div class="d-flex ai-center flex-column body-box">
        <dv-capsule-chart class="dv-cap-chart" :config="config" />
<!--        <centerRight2Chart1 />-->
      </div>
    </div>
  </div>
</template>

<script>
import centerRight2Chart1 from '@/components/echart/centerRight/centerRightChart'
import {mapActions} from "vuex";

export default {
  data() {
    return {
      userData: {
        id: ''
      },
      config: {
        data: []
        // data: [
        //   {
        //     name: '北京',
        //     value: 167
        //   },
        //   {
        //     name: '郑州',
        //     value: 67
        //   },
        //   {
        //     name: '天津',
        //     value: 123
        //   },
        //   {
        //     name: '洛阳',
        //     value: 55
        //   },
        //   {
        //     name: '上海',
        //     value: 98
        //   },
        //   {
        //     name: '西安',
        //     value: 100
        //   },
        // ]
      }
    }
  },
  mounted() {
    this.userData.id = this.$store.state.user.userInfo.id;
    console.log(this.userData.id, 'centerRight1 userData.id')
    console.log('centerRight1 mounted')
    this.init()
  },
  methods: {
    ...mapActions(['topTenRiskPlace']),
    async init() {
      const response = await this.topTenRiskPlace(this.userData.id);
      console.log('接口返回数据centerRight2:', response.data);

      const rawData = response.data;

      this.config = {
        ...this.config,
        data: rawData.map(item => ({
          name: item.name,
          value: item.companyCount
        }))
      };

      console.log('centerRight2 config:', this.config);
    }

  },
  components: { centerRight2Chart1 }
}
</script>

<style lang="scss" scoped>
$box-width: 510px;
$box-height: 250px;

#centerRight2 {
  padding: 16px;
  height: $box-height;
  width: $box-width;
  border-radius: 5px;
  .bg-color-black {
    padding: 5px;
    height: $box-height - 30px;
    //width: $box-width;
    border-radius: 10px;
  }
  .text {
    color: #c3cbde;
    font-size: 15px;
  }
  .body-box {
    border-radius: 10px;
    overflow: hidden;
    .dv-cap-chart {
      width: 100%;
      height: 160px;
    }
  }
}
</style>
